package org.vergil.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import org.vergil.config.dataConfig.DataSourceContextHolder;

/**
 * Created by vergil on 2/20/17.
 */
@Aspect
@Component
public class AopTest {

//    @Pointcut("execution(* org.vergil.test.*.(String))" + "&& args(info)")
//    public void a(String info){}

    @Before("execution(* org.vergil.core.service.*.setInfo(String))" + "&& args(info)")
    public void before(String info){
        System.out.println("before"+info);
    }

    @Before("execution(* org.vergil.core.dao.dev.*.*(..))")
    public void changeDevDataSource(){
        DataSourceContextHolder.setDataSourceType(DataSourceContextHolder.DEV_DB);
    }

    @Before("execution(* org.vergil.core.dao.test.*.*(..))")
    public void changeTestDataSource(){
        DataSourceContextHolder.setDataSourceType(DataSourceContextHolder.TEST_DB);
    }

}
